﻿@model IEnumerable<TracNghiem.Areas.Admin.Models.UserModel>
<div align="center"><h1>QUẢN TRỊ NGƯỜI DÙNG</h1></div>             
<div class="container_12">    
    <div class="grid_12"> 
        <!-- Notification boxes -->
        @if (TempData["msg"] != null)
        {                            
            <span class="notification n-success">@TempData["msg"]</span>
        }
        <div class="bottom-spacing">
            <!-- Button -->
            <div class="float-right">
                <a href="@Url.Action("AddUser","User")" class="button">
                    <span>Thêm mới<img src="@Url.Content("~/Areas/Admin/Content/themes/template/image/plus-small.gif")" width="12" height="9" alt="New article" /></span>
                </a>
            </div>             
        </div>      
        <!-- Example table -->
        @using (Html.BeginForm("CheckedAction", "User", FormMethod.Post, new { id = "CheckedAction", name = "CheckedAction" }))
        { 
            <div class="module">
                <h2><span></span></h2>                    
                <div class="module-table-body">
                    <div class="scrolling">
                        <div class="data-table" style="width:150%">
                            <table id="myTable" class="tablesorter">
                                <thead>
                                    <tr>
                                        <th style="width:4%;">Xóa</th>
                                        <th style="width:4%;">Sửa</th>
                                        <th style="width:4%;">Chọn</th>
                                        <th style="width:4%;">STT</th> 
                                        <th style="width:10%;">Tên đăng nhập</th>
                                        <th style="width:10%;">Mật khẩu</th>
                                        <th style="width:12%;">Họ tên</th>
                                        <th style="width:20%;">Trung tâm</th>
                                        <th style="width:8%;">Trạng thái</th>
                                        <th style="width:10%;">Số điện thoại</th>
                                        <th style="width:15%;">Email</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @{int stt = 0;}
                                    @foreach (var item in Model)
                                    {
                                        stt++; 
                                        <tr>
                                        <td class="align-center">
                                            @if (item.username != "Admin")
                                            {    
                                                <a href="@Url.Action("DeleteUser", "User", new { id = item.id })" onclick="return confirm('Bạn muốn xóa người dùng này?');" title="Xóa thông tin"><img src="@Url.Content("~/Areas/Admin/Content/themes/template/image/cross-on-white.gif")" width="16" height="16" alt="delete" /></a>
                                            } 
                                        </td>     
                                        <td class="align-center">
                                            @if (item.username != "Admin")
                                            {    
                                                <a href="@Url.Action("EditUser", "User", new { id = item.id })" title="Sửa thông tin"><img src="@Url.Content("~/Areas/Admin/Content/themes/template/image/pencil.gif")"  width="16" height="16" alt="edit" /></a>
                                            }                                              
                                        </td>
                                        <td class="align-center">
                                            @if (item.username != "Admin")
                                            {    
                                                <input type="checkbox" name="Items" id="Items[]" value="@item.id"/>
                                            }                                            
                                        </td>
                                        <td class="align-center">@stt</td>
                                        <td>@Html.DisplayFor(modelItem => item.username)</td>
                                        <td>@Html.DisplayFor(modelItem => item.password)</td>
                                        <td>@Html.DisplayFor(modelItem => item.hoten)</td>
                                        <td>@Html.DisplayFor(modelItem => item.ten_trung_tam)</td>
                                        <td>@Html.DisplayFor(modelItem => item.trang_thai)</td>
                                        <td>@Html.DisplayFor(modelItem => item.so_dien_thoai)</td>
                                        <td>@Html.DisplayFor(modelItem => item.mail)</td> 
                                    </tr>
                                    }
                                </tbody>
                            </table>
                        </div>      
                    </div>    
                    <div class="pager" id="pager">
                        <form action="">
                            <div>
                            <img class="first" src="@Url.Content("~/Areas/Admin/Content/themes/template/image/arrow-stop-180.gif")"/>
                            <img class="prev" src="@Url.Content("~/Areas/Admin/Content/themes/template/image/arrow-180.gif")"/> 
                            <input type="text" class="pagedisplay input-short align-center"/>
                            <img class="next" src="@Url.Content("~/Areas/Admin/Content/themes/template/image/arrow.gif")"/>
                            <img class="last" src="@Url.Content("~/Areas/Admin/Content/themes/template/image/arrow-stop.gif")"/> 
                            <select class="pagesize input-short align-center">
                                <option value="10" selected="selected">10</option>
                                <option value="20">20</option>
                                <option value="30">30</option>
                                <option value="40">40</option>
                            </select>
                            </div>
                        </form>
                    </div>
                    <div class="table-apply">
                        <div class="float-right">
                            <a style='cursor:pointer' onclick="return CheckItem();" class="button">
                                <span>Xóa chọn</span>
                            </a>
                        </div> 
                    </div>
                    <div style="clear: both"></div>
                    </div> <!-- End .module-table-body -->
            </div> <!-- End .module -->
        }    
	</div> <!-- End .grid_12 -->
</div> <!-- End .container_12 -->
<!----------------------------------------------------------------->
<script language="javascript" type="text/javascript">
    function CheckItem() {
        var arrCheckboxes = document.getElementsByName('Items');
        var checkCount = 0;
        for (var i = 0; i < arrCheckboxes.length; i++) {
            checkCount += (arrCheckboxes[i].checked) ? 1 : 0;
        }
        if (checkCount > 0) {
            if (confirm("Bạn chắc chắn muốn xóa thông tin đã chọn?"))
                document.forms["CheckedAction"].submit();
            //else
            //document.getElementById('option_0').selected = 'selected';     
        } else {
            alert("Bạn chưa chọn thông tin cần xóa!");
            //document.getElementById('option_0').selected = 'selected';
            return false;
        }
    }
</script>
